<?php

// +----------------------------------------------------------------------
// | 辉腾模块化框架
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 似水星辰 [ 2630481389@qq.com ]
// +----------------------------------------------------------------------
// | 郑州辉腾科技有限公司
// +----------------------------------------------------------------------

namespace app\user\admin;

use app\admin\admin\Base;
use app\user\model\WithdrawAccount as WithdrawAccountModel;
/**
 * 提现账户管理
 * @author 晓风<215628355@qq.com>
 * @package app\cms\admin
 */
class WithdrawAccount extends Base {

    /**
     * 首页
     * @author 晓风<215628355@qq.com>
     * @return mixed
     */
    public function index() {
        cookie('__forward__', $_SERVER['REQUEST_URI']);
        // 查询
        $map = [];        // 排序
        $order = $this->getOrder('id DESC');
        
        $search_fields = [
            ['mobile', '用户账号', 'text'],
            ['user_nickname', '用户昵称', 'text'],           
        ];
        $input = $this->request->param();
        if($input['mobile']){
            $map[] = ['user.mobile','like','%'.$input['mobile'].'%'];
        }
        if($input['user_nickname']){
            $map[] = ['user.user_nickname','like','%'.$input['user_nickname'].'%'];
        }
        $dataList = WithdrawAccountModel::getList($map,$order);
        // 使用ZBuilder快速创建数据表格
        return \service\Format::ins()
		        ->setTopSearch($search_fields)//设置数据
                        ->addColumns([// 批量添加数据列
                            ['id', 'ID'],
                            ['user_id', '注册用户', "callback", function($value, $data) {
                                    return '<img src="' . get_thumb($data['head_img']) . '" height="30px" /> ' . $data['user_nickname'] . '<br />' . $data['mobile'] . '(ID:' . $data["user_id"] . ')';
                                }, '__data__'],
                            ['true_name', '收款人姓名'],
                            ['account_type', '账户类型', 'status', '', ['--', '微信', '支付宝', '银行卡']],
                            ['account_id', '账户'],
                            ['qrcode', '收款码', "picture"],
                            ['is_default', '是否默认', 'status', '', ['否', '是']],
                            ['create_time', '创建时间'],
                            ['right_button', '操作', 'btn']
                        ])
                        ->setRightButtons([
                            ['ident' => 'delete', 'title' => '删除', 'href' => ['delete', ['ids' => '__id__']], 'class' => 'btn btn-xs mr5 btn-flat ajax-get confirm']
                        ]) // 添加右侧按钮
                        ->setData($dataList)
                        ->fetch(); // 渲染模板	
    }
    public function add() { }
    public function edit($id = 0) { }    
}
